<template>
	<div class="box" @click="isClick()">

		<div class="toast-mask" v-show="toast_control">
			<!-- 规则 -->
			<div class="toast success" v-show="success">
				<div class="hezi" style="">
					<div>
						<router-link to="/luckywheel"><button class="button" @click="clickii">是</button></router-link>
					</div>
					<div>
						<router-link to="/"><button class="button" @click="clickii">否</button></router-link>
					</div>
				</div>


			</div>
			<div class="toast end" v-show="end" >
				<div class="toast-container">
					<div class="close" @click.stop="toast_control=false;end=false"></div>
					<div class="toast-content">
						
					</div>
				</div>
			</div>
			

		</div>
	</div>
</template>
<script>
	import qs from 'qs';
	export default {
		data() {
			return {
				toast_control: false,
				success: false,
				complete: false,
				end: false,
				code: '',
				pkid: ''
			};
		},
		created() {


		},
		mounted() {
			var href = window.location.href;
			this.pkid = href.split("pkId=")[1].split("#")[0];
			this.init()
			console.log(this.pkid)


		},
		methods: {
			//此方法初始化调用接口返回是否已签到码
			init() {
				var that = this
				this.axios.post('/api/hd/qiandao/init',
					qs.stringify({
						pkId: that.pkid
					})).
				then((res) => {
					var data = res.data
					that.code = data.code
					console.log(res)
					if (that.code == 2) {
						that.toast_control = true
						that.end = true
					}
					console.log(that.code)

				}).catch((error) => {
					console.log(error)
				})
			},
			clickii() {
				this.code = 2
				this.success = false;
				this.toast_control = false
			},
			isClick() {
				var that = this;
				if (this.code == 0) {
					this.success = true;
					this.toast_control = true
					this.axios.post('/api/hd/qiandao/add',
						qs.stringify({
							pkId: that.pkid
						})).
					then((res) => {
						console.log(res)
					}).catch((error) => {

					})
				} else if (this.code == 2) {
					
					this.toast_control = true;
					this.end=true
					console.log(this.code)
				} else {
					

				}
			}
		}
	};
</script>
<style lang="less" scoped>
	@import "./sign.less";
</style>
